import Vue from 'vue'
import Vuex from 'vuex'

import {
  sysClassifyQuery,
  sysClassifyDelete,
  sysClassifyAdd,
  sysClassifyUpdate,
} from '@/api/admin/exam/sysClassify'

Vue.use(Vuex)

const state = {
  // activeName: 'manage',
  // activeRow: {},
}

const getters = {}

const actions = {
  //试题增删改查
  async sysClassifyList({ commit }, listQuery) {
    let res = await sysClassifyQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async sysClassifyDel({ commit }, row) {
    let res = await sysClassifyDelete(row.id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async sysClassifyADD({ commit }, data) {
    let res = await sysClassifyAdd(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async sysClassifyUPDATE({ commit }, data) {
    let res = await sysClassifyUpdate(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
}

const mutations = {
  // SET_ACTIVENAME: (state, d) => {
  //   state.activeName = d
  // },
  // SET_ACTIVEROW: (state, d) => {
  //   state.activeRow = d
  // },
}

export default {
  state,
  getters,
  actions,
  mutations,
}
